<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="jquery-3.7.0.min.js"></script>
</head>

<body>
  <div class="idperson">
    <form action="">
      <input type="radio" name="identity" value="学生">学生
      <input type="radio" name="identity" value="老师" checked="checked">老师
      <input type="radio" name="identity" value="管理员">管理员
    </form>
  </div>
  <div class="">用户:<input type="text" class="username" placeholder="请输入用户名">
  </div>
  <br>
  <div class="">密码:<input type="text" class="password" placeholder=" 请输入密码">
    <div class=""><button type="submit">登录</button></div>
</body>

<script>
  const submit = document.querySelector('[type=submit]')
  const username = document.querySelector('.username')
  const password = document.querySelector('.password')
  submit.addEventListener('click', function () {
    // console.log(username.value, password.value);
    // 1.创建对象
    const obj = {
      username: username.value,
      password: password.value
    }
    console.log(obj);
    //   $.ajax({
    //     url: "/http://localhost:8080/register1",
    //     type: "POST",
    //     async: false,
    //     data: {
    //       username: obj.username,
    //       password: obj.password
    //       // 传递的数据
    //     },
    //     dataType: "JSON",
    //     success: function (data) {

    //       // 数据传递成功之后做的事
    //     },
    //     error: function (errorMsg) {
    //       console.log(errorMsg); // 打印错误信息
    //     }
    //   });

    // })
    // var settings = {
    //   "url": "http://localhost:8080/register1",
    //   "method": "POST",
    //   "timeout": 0,
    //   "headers": {
    //     "User-Agent": "Apifox/1.0.0 (https://apifox.com)",
    //     "Content-Type": "application/json"
    //   },
    //   "data": "<obj>",
    // };

    // $.ajax(settings).done(function (response) {
    //   console.log(response);
    // });
    var settings = {
      "url": "http://127.0.0.1?username=<username>&password=<password>",
      "method": "GET",
      "timeout": 0,
      "headers": {
        "User-Agent": "Apifox/1.0.0 (https://apifox.com)"
      },
    };

    $.ajax(settings).done(function (response) {
      console.log(response);
    });
  })
</script>

</body>

</html>